package com.zzxz.practicaltrainingsys.service.impl;

import com.zzxz.practicaltrainingsys.vo.ViewNotice;
import com.zzxz.practicaltrainingsys.entity.Notice;
import com.zzxz.practicaltrainingsys.mapper.NoticeMapper;
import com.zzxz.practicaltrainingsys.service.NoticeService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeServiceImpl implements NoticeService {
    @Autowired
    private NoticeMapper noticeMapper;

    @Override
    public List<Notice> queryAllNotice() {
        return noticeMapper.queryAllNotice();
    }

    @Override
    public List<Notice> getNoticeById(Integer id) {
        return noticeMapper.getNoticeById(id);
    }

    @Override
    public ViewNotice getNoticeDetailById(Integer id) {
        return noticeMapper.getNoticeDetailById(id);
    }

    @Override
    public int deleteNoticeById(Integer id) {
        int i = noticeMapper.deleteNoticeById(id);
        return i;
    }

    @Override
    public int insertNotice(Notice notice) {
        int i = noticeMapper.insertNotice(notice);
        return i;
    }

    //分页通知
    @Override
    public List<ViewNotice> getAllNoticesByPage(int pageNum, int pageSize) {
        int offset = (pageNum - 1) * pageSize;
        return noticeMapper.getAllNoticesByPage(offset, pageSize);
    }

    @Override
    public int getTotalNoticeCount() {
        return noticeMapper.getTotalNoticeCount();
    }

    // 在NoticeServiceImpl.java中新增以下方法实现

    @Override
    public List<ViewNotice> getNoticesByStudentId(Integer studentId, int pageNum, int pageSize) {
        int offset = (pageNum - 1) * pageSize;
        return noticeMapper.getNoticesByStudentId(studentId, offset, pageSize);
    }

    @Override
    public int getTotalNoticeCountByStudentId(@Param("studentId") Integer studentId){
        return noticeMapper.getTotalNoticeCountByStudentId(studentId);
    }

    @Override
    public List<ViewNotice> selectNoticePage(int offset, int limit, Integer project_id) {
        return noticeMapper.selectNoticePage(offset, limit, project_id);
    }

    @Override
    public int selectNoticePageTotal(Integer project_id) {
        return noticeMapper.selectNoticePageTotal(project_id);
    }

    @Override
    public List<ViewNotice> getNoticesByProjectId(Integer projectId) {
        return noticeMapper.getNoticesByProjectId(projectId);
    }
}
